package com.zyx.smartdoc.controller;

import com.zyx.smartdoc.common.response.CommonResult;
import com.zyx.smartdoc.entity.User;
import org.springframework.web.bind.annotation.*;

/**
 * 用户接口
 *
 * @author Yaxi.Zhang
 * @apiNote 用户controller
 * @since 2023/1/6 23:34
 */
@RestController
@RequestMapping("/user")
public class UserController {

    /**
     * 添加用户
     *
     * @param user 用户
     * @return 添加的用户
     */
    @PostMapping("/add")
    public CommonResult<User> addUser(@RequestBody User user) {
        return CommonResult.success(user, "添加用户成功");
    }

    /**
     * 获取用户
     *
     * @param id 用户id
     * @return 获取到的用户
     */
    @GetMapping("/{id}")
    public CommonResult<User> getUser(@PathVariable("id") Long id) {
        return CommonResult.success(new User().setId(id).setUserName("诸葛亮").setUserAge(18)
                .setNickName("孔明").setUserAddress("蜀国"), "获取用户成功");
    }

}